<?php
	header ('Content-type: text/plain');
	// Log lines
	$Pg = pg_pconnect ('host=localhost port=5432 user=overwatch password=overwatch dbname=overwatch');
	$Known = pg_fetch_result (pg_query ($Pg, "select count (*) from inbound where seen is true and known is true;"), 0, 0);
	$Unknown = pg_fetch_result (pg_query ($Pg, "select count (*) from inbound where seen is true and known is false;"), 0, 0);
	// Hosts
	foreach (glob ('hosts/*') as $Host) {
		$Hosts [basename ($Host)] = file_get_contents ($Host);
	}
	$Result = array ('known' => $Known, 'unknown' => $Unknown);
	count ($Hosts) and $Result ['hosts'] = $Hosts;
	echo (json_encode ($Result));
?>